# for eachfile in os.listdir(path):
#     if os.path.isdir(path + eachfile):
#         if os.path.exists(path + eachfile + '/label.png'):
#             shutil.copy(path + eachfile + '/label.png', dirpath + eachfile.split('_')[0] + '.png')
#             print(eachfile + ' successfully moved')
import os
import shutil

path = r'/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset/car1000_2/car1000/'
pathlabels = r'/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset/car1000_2/car1000/masks/'

images_dirpath = r'/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset/car1800/images/'
labels_dirpath = r'/dssg/home/zhineng_qt/test_2021_3_18_fu/dataset/car1800/masks/'

for eachfile in os.listdir(pathlabels):
    # if os.path.isdir(path + eachfile):
    #     if os.path.exists(path + eachfile + '/label.png'):
    #         shutil.copy(path + eachfile + '/label.png', dirpath + eachfile.split('_')[0] + '.png')
    #         print(eachfile + ' successfully moved')
    # if os.path.exists(path + eachfile.split('.')[0] + '.jpg'):
    #     print(path + eachfile.split('.')[0] + '.jpg')
    #     base=path + eachfile.split('.')[0] + '.jpg'
    #     shutil.copy(base,images_dirpath +'b_'+ eachfile.split('.')[0] + '.jpg')

        pathlabels2=pathlabels+eachfile
        shutil.copy(pathlabels2,labels_dirpath +'b_'+ eachfile)

    

